package com.meituan.controller;

import com.meituan.dao.CommentRepository;
import com.meituan.pojo.req.CommentReq;
import com.meituan.pojo.resp.BaseResp;
import com.meituan.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
@Api(description = "商品评论管理")
public class CommentController {

    @Autowired
    CommentService commentService;

    @GetMapping("/findBySidAndGid")
    @ApiOperation(" 查询评论。传参：店铺的sid和商品的gid；返回参数：评论内容，用户名，用户头像，评论时间 ----没有分页")
    public BaseResp findAll(@RequestParam("sid") Integer sid, @RequestParam("gid") Integer gid){

        return commentService.findBySidAndGid(sid,gid);
    }

    @PostMapping("/insertComment")
    @ApiOperation("评论")
    public BaseResp insertComment(@RequestBody CommentReq commentReq){

        return  commentService.insert(commentReq);
    }
}
